
import { useRequest } from "ahooks";
import { getHttp } from "../../../api";
import style from "./style.module.scss";
import { NavBar, Toast } from "react-vant";
import { useNavigate } from "react-router-dom";


const Index: React.FC = () => {

    // 礼物列表参数
    const params = {
        page: 1,
        count: 5
    }
    // 参数接口
    interface paramsRawState {
        page: number,
        count: number
    }

    const getGift = (params: paramsRawState) => getHttp(`/health/doctor/verify/v1/findDoctorGiftList`, params);
    const { data: giftList = [] } = useRequest(async () => {
        const resp = await getGift(params);
        return resp.result;
    });
    const navigate = useNavigate()


    return (
        <div>
            <NavBar
                title="我的礼物"
                onClickLeft={() => navigate(-1)}
            />
            <div className={style['giftlist']}>
                {
                    giftList.length > 0 && giftList.map((v: any, i: any) => (
                        <div key={i}>
                            {
                                v.giftId == 1003 && <div key={i} className={style['giftlist-item1']}>
                                    <div className={style['left']}>
                                        <img src={v.giftPic} alt="" />
                                    </div>
                                    <div className={style['right']}>
                                        <p className={style['right-top']}>{v.userNickName}</p>
                                        <p>{v.sendTime}</p>
                                    </div>
                                </div>
                            }
                            {
                                v.giftId == 1001 && <div key={i} className={style['giftlist-item2']}>
                                    <div className={style['left']}>
                                        <img src={v.giftPic} alt="" />
                                    </div>
                                    <div className={style['right']}>
                                        <p>{v.userNickName}</p>
                                        <p>{v.sendTime}</p>
                                    </div>
                                </div>
                            }
                            {
                                v.giftId == 1002 && <div key={i} className={style['giftlist-item3']}>
                                    <div className={style['left']}>
                                        <img src={v.giftPic} alt="" />
                                    </div>
                                    <div className={style['right']}>
                                        <p>{v.userNickName}</p>
                                        <p>{v.sendTime}</p>
                                    </div>
                                </div>
                            }
                        </div>

                    ))
                }
            </div>
        </div>

    )
}

export default Index;
